import subprocess

PYPI_MIRROR = "https://pypi.tuna.tsinghua.edu.cn/simple"

def install(package):
    try:
        subprocess.check_call(["pip", "install", package])
        subprocess.check_call(["pip", "install", "-i", PYPI_MIRROR, package])

    except subprocess.CalledProcessError:
        print(f"Failed to install {package}, continuing with next package.")

with open('requirements.txt') as f:
    packages = f.read().splitlines()

for package in packages:
    install(package)